home *** CD-ROM | disk | FTP | other *** search
- /* Echo.c
-
- The following MPW commands will build the dcmd and copy it to the
- "Debugger Prefs" file in the System folder. The dcmd's name in
- MacsBug will be the name of the file built by the Linker.
-
- C Echo.c
- Link {dcmdLib}dcmdGlue.a.o Echo.c.o {dcmdLib}DRuntime.o {CLibraries}StdCLib.o -o Echo
- BuildDcmd Echo 101
- Echo 'include "Echo";' | Rez -a -o "{systemFolder}Debugger Prefs"
- */
-
- #include <Types.h>
- #include "dcmd.h"
-
-
- void NumberToHex (long number, Str255 hex)
- {
- Str255 digits = "0123456789ABCDEF";
- int n;
-
- strcpy (hex, &".00000000");
- hex[0] = 8;
- for (n = 8; n >= 1; n--)
- {
- hex[n] = digits[number % 16];
- number = number / 16;
- }
- } // NumberToHex
-
-
- pascal void CommandEntry (dcmdBlock* paramPtr)
- {
- short pos, ch;
- long value;
- Boolean ok;
- Str255 str;
-
- switch (paramPtr->request)
- {
- case dcmdInit:
- break;
-
- case dcmdHelp:
- dcmdDrawLine ("\pECHO [params...]");
- dcmdDrawLine ("\p Echo the command line parameters");
- break;
-
- case dcmdDoIt:
- do {
- // Save the position so we can rewind if we get an error
- pos = dcmdGetPosition ();
- ch = dcmdPeekAtNextChar ();
- if (((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z')))
- { // Get the parameter as a text string
- ch = dcmdGetNextParameter (str);
- dcmdDrawLine (str);
- }
- else
- { // Get the parameter as a 32 bit value
- ch = dcmdGetNextExpression (&value, &ok);
- if (ok)
- { // The expression was parsed correctly
- NumberToHex (value, str);
- dcmdDrawLine (str);
- }
- else
- { // The expression contained an error. Get it as a string
- dcmdSetPosition (pos);
- ch = dcmdGetNextParameter (str);
- dcmdDrawLine (str);
- }
- }
- } while (ch != '\n');
- break;
- }
- } // CommandEntry
-